﻿
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LightCAD.Core
{
 
    public class ComponentShape2d
    {
        public string Category { get; set; }
        public string SubCategory { get; set; }
        public string Name { get; set; }
        public string DisplayName { get; set; }
        public string Description { get; set; }

        public Func<LcParameterSet,List<Curve2d>> Generate { get; set; }

    }
    public class ComponentShape2dCollection : KeyedCollection<string, ComponentShape2d>
    {
        protected override string GetKeyForItem(ComponentShape2d item)
        {
            return item.Name;
        }
        public List<string> GetSubCategoryList()
        {
            var list = new List<string>();
            foreach(var item in this)
            {
                if (!list.Contains(item.SubCategory))
                {
                    list.Add(item.SubCategory);
                }
            }
            return list;
        }

        public List<ComponentShape2d> GetShapeList(string subCategory)
        {
            var list = new List<ComponentShape2d>();
            foreach (var item in this)
            {
                if (subCategory == item.SubCategory)
                {
                    list.Add(item);
                }
            }
            return list;
        }
        public ComponentShape2d GetShape(string name)
        {
            return this.FirstOrDefault((item) => item.Name == name);
        }
    }
}
